package com.yunji.framework_template.books.web.controller;
import com.yunji.framework_template.books.orm.persistence.model.BooksTypeRelation;
import com.yunji.framework_template.books.biz.service.BooksTypeRelationService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yunji.framework_template.common.web.Result;
import com.yunji.framework_template.common.web.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by fenglibin on 2019/01/24.
 */
@Controller
@RequestMapping("/booksTypeRelation/")
public class BooksTypeRelationController {

    @Autowired
    BooksTypeRelationService booksTypeRelationService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<BooksTypeRelation>> selectAll(){
        return Result.success(booksTypeRelationService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<BooksTypeRelation> selectByPrimaryKey(Integer id){
        return Result.success(booksTypeRelationService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<BooksTypeRelation>> selectByCondition(BooksTypeRelation record){
        return Result.success(booksTypeRelationService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(BooksTypeRelation record){
        return Result.success(booksTypeRelationService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(BooksTypeRelation record){
        return Result.success(booksTypeRelationService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(BooksTypeRelation record){
        return Result.success(booksTypeRelationService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<BooksTypeRelation>>> selectByPage(Page<BooksTypeRelation> page){
        List<BooksTypeRelation> list = null;
        page = page.sequentialDisplayCalculate(booksTypeRelationService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = booksTypeRelationService.selectByPage(page);
        }
        Page<List<BooksTypeRelation>> result = new Page<List<BooksTypeRelation>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(BooksTypeRelation record){
        return Result.success(booksTypeRelationService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Integer id){
        return Result.success(booksTypeRelationService.deleteByPrimaryKey(id));
    }

}
